testflowbox: Add an example with buttons
authorMatthias Clasen <mclasen@redhat.com>
Wed, 26 Aug 2015 23:48:29 +0000 (19:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 27 Aug 2015 00:00:03 +0000 (20:00 -0400)
This example populates a flow box with buttons, and makes the
flow box children unfocusable, with the intention that the focus
moves directly between the buttons. Currently, keynav does not
work at all in this case.

tests/testflowbox.c

index 4efc9b726c90337dcea954a08c98f4bbc1ca74ec..ad181219f5b184098b6b55f766b80226debecc95 100644 (file)
@@ -22,7 +22,8 @@ enum {
   FOCUS_ITEMS,
   WRAPPY_ITEMS,
   STOCK_ITEMS,
-  IMAGE_ITEMS
+  IMAGE_ITEMS,
+  BUTTON_ITEMS
 };
 
 #define INITIAL_HALIGN          GTK_ALIGN_FILL
@@ -74,6 +75,7 @@ populate_flowbox_focus (GtkFlowBox *flowbox)
     {
       sensitive = TRUE;
       frame = gtk_frame_new (NULL);
+      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
 
       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
       gtk_container_add (GTK_CONTAINER (frame), box);
@@ -111,6 +113,22 @@ populate_flowbox_focus (GtkFlowBox *flowbox)
     }
 }
 
+static void
+populate_flowbox_buttons (GtkFlowBox *flowbox)
+{
+  GtkWidget *widget;
+  gint i;
+
+  for (i = 0; i < 50; i++)
+    {
+      widget = gtk_button_new_with_label ("Button");
+      gtk_widget_show (widget);
+      gtk_container_add (GTK_CONTAINER (flowbox), widget);
+      widget = gtk_widget_get_parent (widget);
+      gtk_widget_set_can_focus (widget, FALSE);
+    }
+}
+
 static void
 populate_flowbox_wrappy (GtkFlowBox *flowbox)
 {
@@ -235,6 +253,8 @@ populate_items (GtkFlowBox *flowbox)
     populate_flowbox_stock (flowbox);
   else if (items_type == IMAGE_ITEMS)
     populate_flowbox_images (flowbox);
+  else if (items_type == BUTTON_ITEMS)
+    populate_flowbox_buttons (flowbox);
 }
 
 static void
@@ -642,6 +662,7 @@ create_window (void)
   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Wrappy");
   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Stock");
   gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Images");
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Buttons");
   gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
   gtk_widget_show (widget);